//
//  CollectionViewCell.m
//  test
//
//  Created by huichen on 2018/6/4.
//  Copyright © 2018年 huichen. All rights reserved.
//

#import "CollectionViewCell.h"

@interface CollectionViewCell ()

@property (nonatomic,strong) UILabel *label;

@end

@implementation CollectionViewCell

- (instancetype)initWithFrame:(CGRect)frame{
    
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor whiteColor];
        self.layer.borderColor = [UIColor lightGrayColor].CGColor;
        self.layer.borderWidth = 1.0;
        
        self.label = [[UILabel alloc] init];
        self.label.textAlignment =NSTextAlignmentCenter;
        self.label.backgroundColor = [UIColor whiteColor];
        self.label.font = [UIFont systemFontOfSize:14];
        self.label.textColor = [UIColor blackColor];
        [self addSubview:self.label];
        
        //btn
        self.deleteBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.deleteBtn.hidden = YES;
        self.deleteBtn.backgroundColor = [UIColor whiteColor];
        [self.deleteBtn setTitleColor:[UIColor lightGrayColor] forState:UIControlStateNormal];
        [self.deleteBtn setTitle:@"x" forState:UIControlStateNormal];
        [self addSubview:self.deleteBtn];
    }
    return self;
}
 
   
- (void)setDataModel:(CellModel *)dataModel{
 
    _dataModel = dataModel;
        self.label.font = [UIFont systemFontOfSize:dataModel.fontSize];
    self.label.frame = self.bounds;
    self.label.text = _dataModel.title;
    
    self.label.textColor = _dataModel.textColor;
    self.backgroundColor = _dataModel.bgColor;
    self.layer.borderColor = _dataModel.borderColor.CGColor;
    self.layer.borderWidth = _dataModel.borderWidth;
    
    self.deleteBtn.hidden = YES;
    self.deleteBtn.frame = CGRectMake(self.bounds.size.width - 20, self.bounds.size.height/2 -10, 20, 20);
 }

 
 - (void)prepareForReuse{
     
     [super prepareForReuse];
     self.deleteBtn.hidden = YES;
 }
@end
